<template>
	<view class="message-index-page container">
		<view class="seed-top">
			<view class="top-list" :class="pageType==='sys'&&'top-list-active'" @click="selTopChange('sys')">系统消息</view>
			<view class="top-list" :class="pageType==='worker'&&'top-list-active'" @click="selTopChange('worker')">客服消息
			</view>
		</view>
		<view class="msg-content">
			<template v-if="(pageType==='sys' && sysList.length>0) || (pageType==='worker' && workerList.length>0)">
				<view v-if="pageType==='sys'">
					<view class="msg-list" v-for="item in sysList" :key="item.id">
						<image class="msg-list-img" :src="$fileUrl+'msg-sys.png'"></image>
						<view class="msg-list-box" @click="jumpSys(item)">
							<view class="msg-list-top">
								<view class="msg-list-name">{{item.title}}</view>
								<view class="msg-list-time">2025-12-25 23:45</view>
							</view>
							<view class="msg-list-bottom">{{item.msg}}</view>
							<text class="prop-number"></text>
						</view>
					</view>
				</view>
				<view v-else>
					<view class="msg-list" v-for="item in workerList" :key="item.id">
						<image class="msg-list-img" :src="$testImg"></image>
						<view class="msg-list-box" @click="jumpMsg(item)">
							<view class="msg-list-top">
								<view class="msg-list-name">{{item.title}}</view>
								<view class="msg-list-time">2025-12-25 23:45</view>
							</view>
							<view class="msg-list-bottom">{{item.msg}}</view>
							<text class="prop-number"></text>
						</view>
					</view>
				</view>
			</template>

			<view class="null-page" v-else>
				<text class="iconfont">&#xe65c;</text>
				<view class="null-page-tips">{{myUserInfo.id?'暂无数据':'请先登录'}}~</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { onMounted, reactive, ref } from 'vue';
	import { getStorage, hideLoading, showLoading } from '@/common/util';

	import { onShow } from "@dcloudio/uni-app"
	const pageType = ref('sys')
	const selTopChange = (type : string) => {
		pageType.value = type
	}

	const jump = (url : string) => {
		const userInfo = getStorage('userInfo') || {}
		if (!userInfo || !userInfo.id) {
			uni.navigateTo({
				url: '/pages/login/index'
			})
			return
		}
		uni.navigateTo({ url })
	}
	const jumpSys = (item) => {
		uni.navigateTo({
			url: '/pages/user/sysDetail'
		})
	}
	const jumpMsg = (item) => {
		uni.navigateTo({
			url: '/pages/user/worker'
		})
	}
	const sysList = ref([
		{ title: '支付成功提醒', id: '1', msg: '您得订单as000002已支付成功，支付金额65.22,感谢您得支持' },
		{ title: '支付成功提醒', id: '2', msg: '您得订单as000002已支付成功，支付金额65.22' },
		{ title: '支付成功提醒', id: '3', msg: '您得订单as000002已支付成功，支付金额65.22' },
	])
	const workerList = ref([
		{ title: '客服001', id: '1', msg: '您好' },
		{ title: '客服002', id: '2', msg: '已修改地址' },
		{ title: '客服003', id: '3', msg: '还有什么可以帮您得吗？' },
	])

	const getList = async () => {
		const userInfo = getStorage('userInfo') || {}
		showLoading()
		try {


		} finally {
			hideLoading()
		}
	}
	const myUserInfo = ref<any>({})
	onShow(async () => {

	})
	onMounted(() => {

	})
</script>

<style lang="scss">
	.message-index-page {
		padding: 20rpx;
		padding-bottom: 120rpx;

		.seed-top {
			background-color: #fff;
		}

		.top-list {
			width: 25%;
			display: inline-block;
			border-bottom: solid 6rpx #fff;
			height: 88rpx;
			line-height: 88rpx;
			text-align: center;
			font-size: 30rpx;
			color: #5B5B5B;
		}

		.top-list-active {
			font-weight: bold;
			color: #17CC77;
			border-bottom: solid 6rpx #17CC77;
		}




		.msg-content {
			background-color: #fcfcfc;
			margin-top: 20rpx;
		}

		.msg-list {
			display: flex;
			align-items: center;
			padding: 0 30rpx;
			height: 150rpx;
			border-top: solid 1px #eee;
		}

		.msg-list-img {
			width: 70rpx;
			height: 70rpx;
		}

		.msg-list-box {
			padding-left: 20rpx;
			flex-grow: 1;
			width: 1px;
			position: relative;

			.prop-number {
				left: -10rpx;
				position: absolute;
				width: 15rpx;
				height: 15rpx;
				display: block;
				padding: 0;
				border-radius: 15rpx;
				top: 0rpx;
				background-color: #FF315A;
			}
		}

		.msg-list-top {
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.msg-list-name {
			font-size: 30rpx;
			color: #333;
		}

		.msg-list-time {
			font-size: 24rpx;
			color: #666;
		}

		.msg-list-bottom {
			font-size: 26rpx;
			color: #999;
			margin-top: 6rpx;
			width: 100%;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}
	}
</style>